package com.m1905hd.entity;


import com.alibaba.druid.util.StringUtils;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @author weiwei.huang
 * @email ihuangweiwei@163.com
 * @date 15/3/30
 */
public class Role {

    private int id;
    private String name;
    private String description;
    private List<Integer> resourceIds;
    private int available;

    public Role() {
    }

    public Role(String name, String description, int available) {
        this.name = name;
        this.description = description;
        this.available = available;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public List<Integer> getResourceIds() {
        return resourceIds;
    }



    public void setResourceIds(String resourceIds) {
        if (StringUtils.isEmpty(resourceIds)) {
            this.resourceIds = Collections.emptyList();
        } else {
            String[] role_ids = resourceIds.split(",");
            this.resourceIds = new ArrayList<Integer>();
            for (String id : role_ids) {
                if (!StringUtils.isEmpty(id)) {
                    this.resourceIds.add(Integer.valueOf(id));
                }
            }
        }
    }

    public int getAvailable() {
        return available;
    }

    public void setAvailable(int available) {
        this.available = available;
    }
}
